<?php
/**
 * @authors alex (20779512@qq.com)
 * @date    2014-03-24 17:25:39
 * @version 1.0
 */

class HelpAction extends BaseAction {

    public function index(){       

        #文章列表
        $map['cid'] = 3;
        $obj = M('Article');
        $count = $obj->where($map)->count();
        import("@.ORG.WapPage");
        $page = new Page($count, 10);
        $show = $page->show();
        $list = $obj->where($map)->order('sort asc , id desc')->limit($page->firstRow . ',' . $page->listRows)->select();

        foreach ($list as $key => $value) {
            if ($value['url']!='') {
                $list[$key]['link']=$value['url'];
            }else{                
                $list[$key]['link']= U('Help/view',array('id'=>$value['id']));
            }
        }

        $this->assign('list', $list);
        $this->assign('page', $show);
        $this->display();
    }     

    public function view(){
        $id = I('get.id');
        if ($id=='') {
            $this->error('参数错误');
        }
        $map['id']=$id;
        $list = M('Article')->where($map)->find();
        M('Article')->where($map)->setInc('hit');
        if (!$list) {
            $this->error('信息不存在');
        } else {
            $this->assign('list', $list);
            $this->display();
        }
    }

}